<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>

    <style>
        .p1~p {
            color: red;
        }
        span~span {
            color: red;
        }
    </style>
</head>
<body>

    <div>
        <p class="p1">1</p>
        <div>上一个会变红吗</div>
        <p class="p1">2</p>
        <p class="p1">3</p>
        <div>222222</div>
        <p>4</p>
        <p>5</p>

        <span>1</span>
        <span>2</span>
         <h1>3</h1>
         <span>4</span>
    </div>
    
</body>
</html>